document.getElementById("save").onclick=function(){
	var name=$("#name").val()
	if(/^ *$/.test(name)){
		showErrorInfo("名称不能为空！")
		return false
	}
	$.ajax({
		"url":"/web_name/",
		"error":errorAjax,
		"beforeSend":start_load_pic,
		"complete":stop_load_pic,
		"data":{"data":name},
		"type":"POST",
		"success":function(data){
			data=JSON.parse(data)
			responseCheck(data)
			location.reload()
		}
	})
}
document.getElementById("b-file").onchange=function(){
	var file=$("#b-file").prop("files")[0]
	var data=new FormData()
	data.append("file",file)
	jQuery.ajax({
		"url":"/background/",
		"type":"POST",
		"data":data,
		"processData":false,
                "contentType": false,
		"error":errorAjax,
		"complete":stop_load_pic,
		"beforeSend":start_load_pic,
                "cache": false,
		"success":function(data){
			responseCheck(data)
			data=JSON.parse(data)
			if(!data.status){
				showErrorInfo(data.content)
				return false
			}
			else{
				showSuccessNotice()
			}
		}
	})
}
document.getElementById("j-file").onchange=function(){
	var file=$("#j-file").prop("files")[0]
	var data=new FormData()
	data.append("file",file)
	jQuery.ajax({
		"url":"/js/",
		"type":"POST",
		"data":data,
		"processData":false,
                "contentType": false,
		"error":errorAjax,
		"complete":stop_load_pic,
		"beforeSend":start_load_pic,
                "cache": false,
		"success":function(data){
			responseCheck(data)
			data=JSON.parse(data)
			if(!data.status){
				showErrorInfo(data.content)
				return false
			}
			else{
				showSuccessNotice()
			}
		}
	})
}
document.getElementById("l-file").onchange=function(){
	var file=$("#l-file").prop("files")[0]
	var data=new FormData()
	data.append("file",file)
	jQuery.ajax({
		"url":"/logo/",
		"type":"POST",
		"data":data,
		"processData":false,
                "contentType": false,
		"error":errorAjax,
		"complete":stop_load_pic,
		"beforeSend":start_load_pic,
                "cache": false,
		"success":function(data){
			responseCheck(data)
			data=JSON.parse(data)
			if(!data.status){
				showErrorInfo(data.content)
				return false
			}
			else{
				showSuccessNotice()
			}
		}
	})
}
function getList(){
	$.ajax({
		"url":"/web_name/",
		"error":errorAjax,
		"beforeSend":start_load_pic,
		"complete":stop_load_pic,
		"type":"GET",
		"success":function(data){
			data=JSON.parse(data)
			responseCheck(data)
			document.getElementById("name").value=data.content
		}
	})
}
getList()
